<?php
class user_groupController extends adminController{

    //首页
    public function index() {
        //获取管理组列表
        $this->list=model('user_group')->group_list();
        $this->show(); 
    }

    //添加
    public function add() {
        $this->action_name='添加';
        $this->action='add';

        //获取tabhtml
        $tab_html=apiHook('hook_user_group_tab_html');
        $this->tab_html=hook_merge($tab_html);

        $this->base_purview=model('user_group')->get_base_purview();
        $this->menu_purview=model('user_group')->get_menu_purview();
        $this->user=$this->getLogin();
        $this->show('user_group/info'); 
        
    }

    public function add_save() {
        //录入模型处理
        $gid=model('user_group')->add($_POST);
        $_POST['gid']=$gid;
        apiHook('hook_user_group_save',$_POST);
        $this->msg('管理组添加成功！',1);
        
    }

    //修改
    public function edit() {
        $gid=$_GET['gid'];
        $this->alert_str($gid,'int');
        $this->info=model('user_group')->info($gid);
        $this->action_name='编辑';
        $this->action='edit';

        //获取tabhtml
        $tab_html=apiHook('hook_user_group_tab_html',$this->info);
        $this->tab_html=hook_merge($tab_html);

        $this->base_purview=model('user_group')->get_base_purview();
        $this->menu_purview=model('user_group')->get_menu_purview();
        $this->user=$this->getLogin();
        $this->show('user_group/info'); 
    }

    public function edit_save() {
        $gid=$_POST['gid'];
        $this->alert_str($gid,'int',true);
        //录入模型处理
        model('user_group')->edit($_POST);
        apiHook('hook_user_group_save',$_POST);
        $this->msg('管理组修改成功! ',1);
    }

    //删除
    public function del() {
        $gid=intval($_POST['gid']);
        $this->alert_str($gid,'int',true); 
        //录入模型处理
        model('user_group')->del($gid);
        apiHook('hook_user_group_del',$gid);
        $this->msg('管理组删除成功！',1);
    }


}